﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using NexTrackDesktop.NexTrack;

namespace NexTrackDesktop.ViewModels
{
    /// <summary>
    /// This method handles/links User info to view
    /// </summary>
    public class UserViewModel : DependencyObject
    {
        private User _user;

        public UserViewModel(User user)
        {
            User = user;
        }

        public User User
        {
            get
            {
                return _user;
            }
            set
            {
                _user = value;
                Update();
            }
        }

        /// <summary>
        /// This method updates the specified User
        /// </summary>
        public void Update()
        {
            FacebookID = _user.FacebookID;
            Name = _user.Name;
            Link = _user.Link.ToString();
            Picture = _user.Picture.ToString();
        }

        /// <summary>
        /// This method gets or sets the specified User FacebookID
        /// </summary>
        public string FacebookID
        {
            get { return (string)GetValue(FacebookIDProperty); }
            set { SetValue(FacebookIDProperty, value); }
        }

        /// <summary>
        /// This method gets or sets the specified User's Name
        /// </summary>
        public string Name
        {
            get { return (string)GetValue(NameProperty); }
            set { SetValue(NameProperty, value); }
        }

        /// <summary>
        /// This method gets or sets the specified User's Link
        /// </summary>
        public string Link
        {
            get { return (string)GetValue(LinkProperty); }
            set { SetValue(LinkProperty, value); }
        }

        /// <summary>
        /// This method gets or sets the specified User's Picture
        /// </summary>
        public string Picture
        {
            get { return (string)GetValue(PictureProperty); }
            set { SetValue(PictureProperty, value); }
        }

        // Using a DependencyProperty as the backing store for FacebookID.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty FacebookIDProperty =
            DependencyProperty.Register("FacebookID", typeof(string), typeof(UserViewModel), new UIPropertyMetadata(null));

        // Using a DependencyProperty as the backing store for Name.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty NameProperty =
            DependencyProperty.Register("Name", typeof(string), typeof(UserViewModel), new UIPropertyMetadata(null));

        // Using a DependencyProperty as the backing store for Link.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty LinkProperty =
            DependencyProperty.Register("Link", typeof(string), typeof(UserViewModel), new UIPropertyMetadata(null));

        // Using a DependencyProperty as the backing store for Picture.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty PictureProperty =
            DependencyProperty.Register("Picture", typeof(string), typeof(UserViewModel), new UIPropertyMetadata(null));
    }
}